﻿using Lsk.Business;
using Lsk.Business.DTO;
using Lsk.Data;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace lsk.Web.Api
{
    public class UserController : ApiController
    {
        [HttpPost]
        public HttpResponseMessage save(dynamic data)
        {
            LoginInfo entry = JsonConvert.DeserializeObject<LoginInfo>(data.ToString());
            Users usm = new Users();
            return Request.CreateResponse(HttpStatusCode.OK, usm.Save(entry));
        }

        [HttpPost]
        public HttpResponseMessage saveFb(dynamic data)
        {
            LoginInfo entry = JsonConvert.DeserializeObject<LoginInfo>(data.ToString());
            Users usm = new Users();
            return Request.CreateResponse(HttpStatusCode.OK, usm.SaveFbUser(entry));
        }

        [HttpPost]
        public HttpResponseMessage userForgetPassword(dynamic data)
        {
            LoginInfo entry = JsonConvert.DeserializeObject<LoginInfo>(data.ToString());
            Users usm = new Users();
            usm.SendPasswordReset(entry);
            return Request.CreateResponse(HttpStatusCode.OK, "ok");
        }

        [HttpPost]
        public HttpResponseMessage sendEmail(dynamic data)
        {
            EmailMessage entry = JsonConvert.DeserializeObject<EmailMessage>(data.ToString());
            Users usm = new Users();
            usm.SendEmailMsg(entry);
            return Request.CreateResponse(HttpStatusCode.OK, "ok");
        }

        [HttpGet]
        public IEnumerable<GetAgents_Result> GetAgentList()
        {
            Users usm = new Users();
            return usm.GetAgentList();
        }

        [HttpGet]
	        public IEnumerable<GetAgentDetail_Result> GetAgentDetail(string id)
	        {
	            Users usm = new Users();
	            return usm.GetAgentDetail(id);
	        }

}
}
